﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace ExoticCarRental
{
    public partial class MyReservations : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["UserSettings"] == null)
            {
                Response.Redirect("login.aspx");
            }

            string email = Request.Cookies["UserSettings"]["email"];

           

            BusinessLayer bl = new BusinessLayer();
            string reservation_id = Request.QueryString["id"];
            if (reservation_id != null)
            {
                int reservationid;
                if (Int32.TryParse(reservation_id, out reservationid))
                {
                    //delete reservation
                    int status = bl.DeleteReservation(reservationid);

                }
            }

            if (!IsPostBack)
            {
                //get the email from the cookie, if cookie is empty redirect to login
                DataTable dt = bl.GetMyReservations(email);
                grdReservations.DataSource = dt;
                grdReservations.DataBind();



            }
        }

        protected void grdReservations_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

  
    }
}
